﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodingWiki_Model.Models
{
    //    <Nullable>enable</Nullable> 去掉就不会 提示 设置 xxx 可以为空
    public class Book
    {
        //[Key] //必须有主键 或者命名为ID 或 BookId  className+Id
        public int BookId { get; set; }
        public string Title { get; set; }
        [MaxLength(20)]
        [Required]
        public string ISBN { get; set; }
        public decimal Price { get; set; }

        [NotMapped] //不映射
        public string PriceRange { get; set; }

        public BookDetail BookDetail { get; set; }

        //外键链接Publisher表 1对多
        [ForeignKey("Publisher")]
        public int Publisher_Id { get; set; }
        public Publisher Publisher { get; set; }

        //多对多 会创建一个中间表 
        public List<BookAuthorMap> BookAuthorMap { get; set; }
    }
}
